package cn.itcast.com.List;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class iterator {
    public static void main(String[] args) {
        /*
        移动cursor
        E next()
        E previous() 在光标使用next之后，后面指向next，前面指向previous
        nextIndex  返回iter的next的索引
        previous  itrer之前的索引
        add  cursor会+1
         */
        List list = new ArrayList();
        list.add("hello");
        list.add("world");
        list.add(2,"cskaoyan");
        ListIterator it = list.listIterator();
        Object next = it.next();
        Object previous = it.previous();
        System.out.println(next);
        it.remove();
        Object next1 = it.next();
        System.out.println(next);
        System.out.println(list);
    }
}
